<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <form name="form1">
        <h2>form1</h2>
        <p id="p1">
            <input type="radio" name="gender" value="boy"> 男
            <input type="radio" name="gender" value="gril"> 女
        </p>
    </form>
    <script>
        console.log(document.form1.gender);
        document.getElementById('p1').oninput = function () {
            console.log(document.form1.gender.value);
        }
        // document.getElementById('p1').onchange = function () {
        //     console.log(document.form1.gender.value);
        // }
        // document.form1.gender[0].onchange = function () {
        //     console.log(document.form1.gender.value);
        // }
        // document.form1.gender[1].onchange = function () {
        //     console.log(document.form1.gender.value);
        // }
    </script>
</body>

</html>